/**
 * 
 */
package com.gua.jbs.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.gua.jbs.service.IInvoiceService;
import com.gua.jbs.serviceImpl.InvoiceService;
import com.gua.jbs.utility.ApplicationConstant;
import com.gua.jbs.utility.ApplicationException;
import com.gua.jbs.utility.StringUtil;



/**
 * @author Yogesh Sapkal
 * 
 * Gerenate Invoice Number
 *
 */
public class InvoiceController extends BaseController{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static final Logger logger = Logger
			.getLogger(LoginController.class);

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		IInvoiceService invoiceService=new InvoiceService();
		String action = request.getParameter(ApplicationConstant.ACTION);
		if (StringUtil.isNullOrEmpty(action) && action.equals(ApplicationConstant.GET_INVOICE_NO)) {
		
			try {
				List<String> invoiceNo=invoiceService.generatedInvoice();
				
				logger.info("invoice list---->"+invoiceNo.size());
			} 
			catch (ApplicationException e) {
				// TODO Auto-generated catch block
				logger.error("InvoiceController : generated() ----> "
						+ e.getMessage());
				e.printStackTrace();
			}
		}
		else if (StringUtil.isNullOrEmpty(action) && action.equals(ApplicationConstant.UPDATE_INVOICE_NO)) {
			
			String invoiceId = request.getParameter(ApplicationConstant.INVOICE_ID);
			String invoiceValue = request.getParameter(ApplicationConstant.INVOICE_VALUE);
			/*try {
				boolean isUpdate=false;
				
				//isUpdate=invoiceService.updateInvoice(invoiceId,invoiceValue);
				
				logger.info("invoice list---->"+isUpdate);
			} */
			/*catch (ApplicationException e) {
				// TODO Auto-generated catch block
				logger.error("InvoiceController : generated() ----> "
						+ e.getMessage());
				e.printStackTrace();
			}*/
		}
		
	}
	

}
